package com.zhengke.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhengke.dao.TvUserOperaDao;
import com.zhengke.pojo.BaleGoods;
import com.zhengke.pojo.TvUserOpera;
import com.zhengke.pojo.Result;
import com.zhengke.service.TvUserOperaService;

/**  

* 创建时间：2020年1月4日 下午2:53:28  

* 项目名称：tvmall  

* @author 刘浩  

* @version 1.0     

* 文件名称：TvUserOperaServiceImpl.java   

* 类说明：  

*/
@Service
public class TvUserOperaServiceImpl implements TvUserOperaService{
	Result rs = new Result();
	@Autowired
	TvUserOperaDao tuod;
	@Override
	public Result selectTvUserOpera(TvUserOpera tuo) {
		PageHelper.startPage(tuo.getPage(), tuo.getLimit(),true);
		List<TvUserOpera> selectTvUserOperaList = tuod.selectTvUserOpera(tuo);
		PageInfo<TvUserOpera> pageInfo = new PageInfo<TvUserOpera>(selectTvUserOperaList);
		rs.setCount(Integer.parseInt(String.valueOf(pageInfo.getTotal())));
		rs.setData(selectTvUserOperaList);
		rs.setCode(0);
		rs.setMsg("success");
		return rs;
	}

	@Override
	public Result StatisticsTvUserOpera(TvUserOpera tuo) {
		PageHelper.startPage(tuo.getPage(), tuo.getLimit(),true);
		List<TvUserOpera> statisticsTvUserOperaList = tuod.StatisticsTvUserOpera(tuo);
		List<TvUserOpera> statisticsTvUserOperaList1 = new ArrayList<TvUserOpera>();
		for(int i = 0;i<statisticsTvUserOperaList.size();i++) {
			TvUserOpera tvUserOpera = statisticsTvUserOperaList.get(i);
			tvUserOpera.setId(i+1+"");
			statisticsTvUserOperaList1.add(tvUserOpera);
		}
		int count =  tuod.StatisticsTvUserOperaCount(tuo);
		rs.setCount(count);
		rs.setData(statisticsTvUserOperaList1);
		rs.setCode(0);
		rs.setMsg("success");
		return rs;
	}



}
